<?php
namespace app\index\model;
use think\Model;
class Category  extends Model
{

    protected $autoWriteTimestamp = 'datetime';//自动生成当前时间戳
    //无限极分类
    public static function getTree($arr)
    {
        static $list=[];
        if(!empty($arr)){
            foreach ($arr as $k=>$v){
                $list[$v['id']] = $v;
            }
            static $tree=[];
            foreach ($list as $value){
                if(isset($list[$value['p_id']])){
                    $list[$value['p_id']]['child'][] = &$list[$value['id']];
                }else{
                    $tree[] = &$list[$value['id']];
                }
            }

        }
        return $tree;
    }


}